﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TalentMatrixMgr : MonoBehaviour {

    private Dictionary<int, List<Vector2>> m_Pos = new Dictionary<int, List<Vector2>>();
    private RectTransform m_rec;
    public GameObject m_talentObj;
    public GameObject m_talentObj_square;

    private void Awake()
    {
        m_rec = transform as RectTransform;
        m_talentObj.SetActive(false);
        m_talentObj_square.SetActive(false);
        OnCreateMatrix();

    }

    void Start () {


    }

    void OnCreateMatrix()
    {
        float width = m_rec.sizeDelta.x;
        float hight = m_rec.sizeDelta.y;

        for (int i = 1; i <= 11; i++)
        {
            List<Vector2> list = new List<Vector2>();
            for (int j = 1; j <= 17; j++)
            {
                Vector2 v = new Vector2(i * width / 11, -j * hight / 17);
            
                list.Add(v);
            }
            m_Pos.Add(i, list);
        }
    }
    
    public GameObject OnShowItem(string x, string y,string objname,bool isSquare)
    {
        GameObject go;
        if (!isSquare)
            go = Instantiate(m_talentObj);
        else
            go = Instantiate(m_talentObj_square);
        go.SetActive(true);
        go.transform.SetParent(this.transform, false);
        go.transform.localPosition = m_Pos[int.Parse(x)][int.Parse(y)-1];
        go.name = objname;

        return go;

    }


    void Update () {
		
	}
}
